package org.qqcui.designpattern.patterns.iterator;

import java.util.Iterator;

/**
 * 计算机学院迭代器
 *
 * @author cuiqingqiang
 * @version 1.0
 * @date 2022/5/6 14:12
 **/
public class ComputeCollegeIterator implements Iterator<Department> {

    /**
     * 计算机学院下的专业，使用数组的方式存储
     */
    private Department[] departments;

    /**
     * 数组下标
     */
    private int index = 0;

    public ComputeCollegeIterator(Department[] departments) {
        this.departments = departments;
    }

    @Override
    public boolean hasNext() {
        if (index >= departments.length || departments[index] == null) {
            return false;
        } else {
            return true;
        }
    }

    @Override
    public Department next() {
        Department department = departments[index];
        index++;
        return department;
    }

    @Override
    public void remove() {

    }
}
